package com.qinaxiwit.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qianxi.wit.pojo.TbConsult;
import com.qianxi.wit.pojo.TbDoctor;
import com.qianxi.wit.result.R;
import com.qinaxiwit.service.TbConsultService;
import com.sun.org.apache.bcel.internal.generic.NEW;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zqp
 * @since 2021-01-14
 */
@RestController
public class TbConsultController {
    @Autowired
    private TbConsultService consultService;

    //点击咨询，生成问诊记录[订单]
    @PostMapping("/insert")
    TbConsult insert(@RequestBody TbConsult consult){
        try {
            return consultService.insert(consult);
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }

    //快速问诊医生列表页面，查询时绑定doctor对象中的doctor_name属性去查询
    @PostMapping("/findDoctor/{page}/{size}/{ids}")
    Page<TbDoctor> findbydoctor(@PathVariable("page") int page,
                                @PathVariable("size") int size,
                                @PathVariable("ids") Long[] ids,
                                @RequestBody TbDoctor doctor){
        try {
            Page<TbDoctor> page1 = consultService.findbydoctor(page,size,ids,doctor);
            System.out.println(page1);
            return page1;
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }

    @PostMapping("/patientName")
    List<TbConsult> selectList(@RequestBody String patientName){
        try {
            return consultService.selectLIst(patientName);
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }
}

